﻿//********************************************************************************//
//创建日期：<创建日期，2010-08-02>
//创建作者：<王一飞，wangyifei@shanghai3h.com>
//功能说明：S_SETTINGSBLL层
//********************************************************************************//
namespace BLL
{
    using System;
    using System.Data;
    using Access;
    using Entity;
    public class S_SETTINGSBLL : S_SETTINGSProcess
    {
        #region Field
        private string ConnectionString;
        #endregion
        #region
        public S_SETTINGSBLL()
        {
            ConnectionString = base.conn;
        }
        #endregion
        #region 公共方法
        public string JinRuXiaYiZhangWuNY(S_SETTINGS M_SETTINGS)
        {
            int y = 0;
            int m = 0;
            string _ErrMsg = "";
            try
            {
                y = Convert.ToInt32(M_SETTINGS.CONFIGVALUE) / 100;
                m = Convert.ToInt32(M_SETTINGS.CONFIGVALUE) % 100;
            }
            catch
            {
                _ErrMsg = "账务年月转换出错";
                return _ErrMsg;
            }
            if (m == 12)
            {
                y += 1;
                m = 1;
            }
            else
            {
                m += 1;
            }
            M_SETTINGS.CONFIGVALUE = (y * 100 + m).ToString();
            if (!InsertOrUpdate(M_SETTINGS))
            {
                _ErrMsg = "执行操作出错，请重试或联系相关技术人员解决";
            }
            return _ErrMsg;
        }
        public S_SETTINGS GetCurrentZhangWuNY()
        {
            S_SETTINGS _S_SETTINGS = new S_SETTINGS(); 
            DataTable dt = SelectS_SETTINGsDynamic("KEYNAME = 'ZW_Y_M'", "");
            if ((dt == null) || (dt.Rows.Count == 0))
            {
                _S_SETTINGS.ID = 0;
                _S_SETTINGS.KEYNAME = "ZW_Y_M";
                _S_SETTINGS.CONFIGVALUE = (DateTime.Now.Year * 100 + DateTime.Now.Month).ToString();
                _S_SETTINGS.REMARK = "当前账务年月";
            }
            else
            {
                DataRow dr = dt.Rows[0];
                _S_SETTINGS.ID = Convert.ToDecimal(dr["ID"]);
                _S_SETTINGS.KEYNAME = dr["KEYNAME"].ToString();
                _S_SETTINGS.CONFIGVALUE = dr["CONFIGVALUE"].ToString();
                _S_SETTINGS.REMARK = dr["REMARK"].ToString();
            }
            return _S_SETTINGS;
        }
        #endregion
        #region 私有方法
        #endregion

    }
}